﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZLCMS.Business.DwzFrame;
using ZLCMS.Business.Util;
using DotNet.Common.Command;
using ZLCMS.Commands.Sys.Commands.User;

namespace ZLCMS.Web.SystemManage.Basics.RightConfig.User
{
    public partial class UserList : System.Web.UI.Page
    {
        protected FrameHelper _framePage;

        protected string Province { get; set; }

        protected string City { get; set; }

        protected string Area { get; set; }

        protected void Page_Load(object sender, EventArgs e)
        {
            Province = string.IsNullOrEmpty(Request["Province"]) ? "-1" : Request["Province"];
            City = string.IsNullOrEmpty(Request["City"]) ? "-1" : Request["City"];
            Area = string.IsNullOrEmpty(Request["Area"]) ? "-1" : Request["Area"];

            _framePage = new FrameHelper(this);
            name.Text = Request["name"];
            code.Text = Request["code"];
            ParamKit.Bind("Roles", role, null, new List<ListItem>() { ParamKit.ParamItemEx_QXZ() }, null,
                string.IsNullOrEmpty(Request["role"]) ? "-1" : Request["role"], "-1");

            LoadUserListParameter param = new LoadUserListParameter();
            param.PageSize = _framePage.IsAjaxPagerPostBack ? _framePage.PageSize : 20;
            param.PageIndex = _framePage.IsAjaxPagerPostBack ? _framePage.PageIndex : 1;
            param.UserName = Request["name"];
            param.RoleCode = Request["role"];
            param.UserCode = Request["code"];
            param.Province = Province;
            param.City = City;
            param.Area = Area;
            ICommandResult<LoadUserListResult> result = new LoadUserListCommand().Execute(param);
            if (!result.Error)
            {
                _framePage.RecordCount = result.TotalCount;
                repeater1.DataSource = result.Result.List;
                repeater1.DataBind();
            }
            CityCascadeCombox1.SelectedValue = City;
            ProvinceCascadeCombox1.SelectedValue = Province;
            AreaCascadeCombox1.SelectedValue = Area;
        }
    }
}
